//获取矩阵数组axa阵
function createFormation_xy(start, section_w, section_h, row, column) {

  var matrix = new Array(row);
  for (var i = 0; i < row; i++) {
    matrix[i] = new Array(column);
    for (var j = 0; j < column; j++) {
      matrix[i][j] = new BABYLON.Vector3(start.x + section_w * j, start.y + section_h * i, 0);
    }
  }

  var index=0;
  var formation = new Array(row*column);
  for (var i = 0; i < row; i++) {
    for (var j = 0; j < column; j++) {
      formation[index] = matrix[i][j];
      index++;
    }
  }

  return formation;
}

function createFormation_xyz(start, section_x, section_y, section_z, x, y, z) {
  var matrix = new Array(x);
  for (var i = 0; i < x; i++) {
    matrix[i] = new Array(x);
    for (var j = 0; j < y; j++) {
      matrix[i][j] = new Array(y);
      for (var k = 0; k < z; k++) {
        matrix[i][j][k] = new BABYLON.Vector3(start.x + section_x * j, start.y + section_y * i, start.z + section_z * k);
      }
    }
  }

  var index=0;
  var formation = new Array(x*y*z);
  for (var i = 0; i < x; i++) {
    for (var j = 0; j < y; j++) {
      for (var k = 0; k < z; k++) {
        formation[index] = matrix[i][j][k];
        index++;
      }
    }
  }

  return formation;
}

function createFormation_circle(center,r,count){
  var formation = new Array(count);

  var PI = 3.14;
  var angle = 2*PI/count;

  var icount = count/4;
  r=r/4;
  angle=4*angle;
  for(var i=0; i<icount; i++){
    formation[i] = new BABYLON.Vector3(r*Math.cos(angle*i), 0 , r*Math.sin(angle*i));
  }
  for(var i=1*icount; i<2*icount; i++){
    formation[i] = new BABYLON.Vector3(r*Math.cos(angle*i), 5 , r*Math.sin(angle*i));
  }
  for(var i=2*icount; i<3*icount; i++){
    formation[i] = new BABYLON.Vector3(r*Math.cos(angle*i), 10 , r*Math.sin(angle*i));
  }
  for(var i=3*icount; i<4*icount; i++){
    formation[i] = new BABYLON.Vector3(r*Math.cos(angle*i), 15 , r*Math.sin(angle*i));
  }

  return formation;
}
